import java.util.ArrayList;

public class Square extends Shape
{
	private final Point initialPoint;
	private final double orientation;
	private final double sideLength;
	
	public Square(Point initialPoint, double orientation, double sideLength)
	{
		if(initialPoint == null || sideLength < 0 || orientation < 0 || orientation > 2 * Math.PI)
		{
			throw new IllegalArgumentException();
		}
		this.initialPoint = initialPoint;
		this.orientation = orientation;
		this.sideLength = sideLength;
	}
	@Override
	public double getArea()
	{
		return Math.pow(sideLength,2.0d);
	}
	
	@Override
	public double getPerimeter()
	{
		return 4 * sideLength;
	}
	
	public ArrayList<Point> getSequenceOfPointsToDraw()
	{
		ArrayList <Point> points = new ArrayList <Point>();
		points.add(initialPoint);
		
		Point nonOrientedSecondPoint = new Point(initialPoint.getX(), initialPoint.getY()+sideLength);
		points.add(nonOrientedSecondPoint.rotate(initialPoint, orientation));
		
		Point nonOrientedThirdPoint = new Point(initialPoint.getX()+sideLength, initialPoint.getY() +sideLength);
		points.add(nonOrientedThirdPoint.rotate(initialPoint, orientation));
		
		Point nonOrientedForthPoint = new Point(initialPoint.getX()+sideLength, initialPoint.getY());
		points.add(nonOrientedForthPoint.rotate(initialPoint, orientation));
		
		return points;
	}
}
